package com.qinggeng.project.system.controller;

import com.qinggeng.common.utils.poi.ExcelUtil;
import com.qinggeng.framework.aspectj.lang.annotation.Log;
import com.qinggeng.framework.aspectj.lang.enums.BusinessType;
import com.qinggeng.framework.web.controller.BaseController;
import com.qinggeng.framework.web.domain.AjaxResult;
import com.qinggeng.framework.web.page.TableDataInfo;
import com.qinggeng.project.system.domain.OrdersEvaluate;
import com.qinggeng.project.system.service.IOrdersEvaluateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;
/**
 * 订单评价Controller
 *
 * @author qinggeng
 * @date 2020-06-19
 */
@RestController
@RequestMapping("/system/orderEvaluate")
public class OrdersEvaluateController extends BaseController
{
    @Autowired
    private IOrdersEvaluateService ordersEvaluateService;

    /**
     * 查询订单评价列表
     */
    @PreAuthorize("@ss.hasPermi('system:orderEvaluate:list')")
    @GetMapping("/list")
    public TableDataInfo list(OrdersEvaluate ordersEvaluate)
    {
        startPage();
        List<OrdersEvaluate> list = ordersEvaluateService.selectOrdersEvaluateList(ordersEvaluate);
        return getDataTable(list);
    }

    /**
     * 导出订单评价列表
     */
    @PreAuthorize("@ss.hasPermi('system:orderEvaluate:export')")
    @Log(title = "订单评价", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(OrdersEvaluate ordersEvaluate)
    {
        List<OrdersEvaluate> list = ordersEvaluateService.selectOrdersEvaluateList(ordersEvaluate);
        ExcelUtil<OrdersEvaluate> util = new ExcelUtil<OrdersEvaluate>(OrdersEvaluate.class);
        return util.exportExcel(list, "evaluate");
    }

    /**
     * 获取订单评价详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:orderEvaluate:query')")
    @GetMapping(value = "/{ordersEvaluateId}")
    public AjaxResult getInfo(@PathVariable("ordersEvaluateId") Long ordersEvaluateId)
    {
        return AjaxResult.success(ordersEvaluateService.selectOrdersEvaluateById(ordersEvaluateId));
    }

    /**
     * 新增订单评价
     */
    @PreAuthorize("@ss.hasPermi('system:orderEvaluate:add')")
    @Log(title = "订单评价", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OrdersEvaluate ordersEvaluate)
    {
        return toAjax(ordersEvaluateService.insertOrdersEvaluate(ordersEvaluate));
    }

    /**
     * 修改订单评价
     */
    @PreAuthorize("@ss.hasPermi('system:orderEvaluate:edit')")
    @Log(title = "订单评价", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OrdersEvaluate ordersEvaluate)
    {
        return toAjax(ordersEvaluateService.updateOrdersEvaluate(ordersEvaluate));
    }

    /**
     * 删除订单评价
     */
    @PreAuthorize("@ss.hasPermi('system:orderEvaluate:remove')")
    @Log(title = "订单评价", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ordersEvaluateIds}")
    public AjaxResult remove(@PathVariable Long[] ordersEvaluateIds)
    {
        return toAjax(ordersEvaluateService.deleteOrdersEvaluateByIds(ordersEvaluateIds));
    }
}
